package com.idanchuang.count.service.api.client;

import com.idanchuang.count.service.api.request.command.CountBatchResetCommand;
import com.idanchuang.count.service.api.request.query.CountBatchQuery;
import com.idanchuang.count.service.api.request.query.CountQuery;
import com.idanchuang.component.base.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * @author Richard_yyf
 * @version 1.0 2021/9/18
 */
@FeignClient(value = "count-service", contextId = "count-service.base.simple-count")
public interface SimpleCountClient {

    String PREFIX = "/base/simple-count";

    /**
     * 计数查询
     * @param countQuery query
     * @return 当前计数的值
     */
    @PostMapping(PREFIX + "/query")
    JsonResult<Long> query(@RequestBody CountQuery countQuery);

    /**
     * 批量计数查询
     * @param countBatchQuery query
     * @return <key: bizId, value: bizId当前计数的值>
     */
    @PostMapping(PREFIX + "/batchQuery")
    JsonResult<Map<String, Long>> batchQuery(@RequestBody CountBatchQuery countBatchQuery);

    /**
     * 对单一业务下的计数器做批量重置
     * @param countBatchResetCommand 重置命令
     * @return result
     */
    @PostMapping(PREFIX + "/batchResetCount")
    JsonResult<Void> batchResetCount(@RequestBody CountBatchResetCommand countBatchResetCommand);
}
